package com.jf.blog.util;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.Random;
import java.util.UUID;

public class MyUtils {
    /**
     * 随机生成token
     */
    public static String createToken() {
        return DigestUtils.md5Hex(UUID.randomUUID().toString());
    }

    public static String getDefaultPassword(String idCard) {
        /*截取身份证后4位*/
        String id = idCard.substring(12);
        return "JF@" + id;
    }

    public static String createSlat() {
        return UUID.randomUUID().toString().substring(0, 6);
    }

    public static String getSlatPassword(String password, String slat) {
        return DigestUtils.md5Hex(password + "-" + slat);
    }

    public static String getMsmCode() {
        String code = "";
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            code += random.nextInt(10);
        }
        return code;
    }

    public static void main(String[] args) {
        System.out.println(getDefaultPassword("320323199202236035"));
    }
}
